import requests
import app

class IhrmEmpManageApi:
    def __init__(self):
        self.url=app.BASE_URL+"/api/sys/user"
    def login_token(self,reqData):
        resp=requests.post(url=app.BASE_URL+"/api/sys/login",headers=app.HEADERS,json=reqData)
        app.TOKEN="Bearer "+resp.json().get("data")
        app.HEADERS["Authorization"]=app.TOKEN
    def add_emp(self,reqData):
        resp=requests.post(url=self.url,headers=app.HEADERS,json=reqData)
        return resp
    def query_emp(self,emp_id):
        resp=requests.get(url=app.BASE_URL+"/api/sys/user/"+emp_id,headers=app.HEADERS)
        return resp
    def modify_emp(self,emp_id,reqData):
        resp = requests.put(url=self.url+"/"+emp_id,headers=app.HEADERS,json=reqData)
        return resp
    def deletd_emp(self,emp_id):
        return requests.delete(url=self.url+"/"+emp_id,headers=app.HEADERS)
    def query_emp_list(self):
        return requests.get(url=app.BASE_URL+"/api/sys/user?page=1&size=10",headers=app.HEADERS)
